<?php

global $connect;
$query = "SELECT cat.nomcategorie AS 'CATEGORIE',prd.nproduit AS NPRODUIT,  prd.marque AS 'MARQUE',em.cellule, em.quantite, em.maxi  FROM produits prd
    LEFT JOIN categories cat ON (cat.ncategorie = prd.ncategorie)
    LEFT JOIN emplacements em ON (prd.nproduit = em.nproduit)
  WHERE em.nmagasin = '".$_GET['show_mag_id']."' ORDER BY cat.nomcategorie;";

$mag = mysql_query($query) or die(mysql_error());

if (isset($_GET['edit_prod_id']))
include ('pages/edit_prod.php');
else
{
echo "<center><h1><a href='index.php?page=produits&action=add&idmag=".$_GET['show_mag_id']."'><img src='img/list-add.png'  width='20px' height='20px'/> Ajouter un produit </a></h1><c/enter> <br /> <br />";
?>
<h1>Liste des produits en Magasins</h1>
	<table frame="border" border="1" cellspacing="0">
		<thead>
			<tr> <th>Marque</th> <th>Categories</th> <th>Cellule</th> <th>Quantite</th> <th>Maximum</th> <th> actions</th></tr>
		</thead>
		<tbody>
		<?php
			while ($data = mysql_fetch_array($mag))
			{
				echo "<tr > <td align='center' width='120px'>".$data['MARQUE']." </td>";
				echo "<td align='center' width='120px'>".$data['CATEGORIE']." </td>";
				echo "<td align='center' width='120px'>".$data['cellule']." </td>";
				echo "<td align='center' width='120px'>".$data['quantite']." </td>";
				echo "<td align='center' width='120px'>".$data['maxi']." </td>";
				echo "<td align='center' width='120px'> 
					<a href='index.php?page=magasins&show_mag_id=".$_GET['show_mag_id']."&edit_prod_id=".$data['NPRODUIT']."'><img src='img/basket.png' alt='modifier'width='20px' height='20px'/></a> 
					<a href='index.php?page=magasins&action=show_mag&del_shop_id=".$data['NPRODUIT']."'><img src='img/Delete.png' alt='supprimer' width='20px' height='20px'/></a></td></tr>";
				
				
			}
	}	?>
		</tbody>
	</table>
	